#include<bits/stdc++.h>
using namespace std;
#define int long long

int fun(int n, vector<vector<int>> nums) {
	vector<int> x, y;
	for (int i = 0; i < n; i++) {
		x.push_back(nums[i][0]);
		y.push_back(nums[i][1]);
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	vector<int> lastSumX(n), lastSumY(n);
	for (int i = n - 1; i >= 0; i--) {
		if (i != n - 1) {
			lastSumX[i] = lastSumX[i + 1] + x[i + 1];
			lastSumY[i] = lastSumY[i + 1] + y[i + 1];
		}
	}

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		ans += lastSumX[i] - (n - i - 1) * x[i];
		ans += lastSumY[i] - (n - i - 1) * y[i];
	}
	return ans;
}

signed main() {
	for (int ii = 1; ii <= 3; ii++) {
		random_device sd;
		mt19937 mt(sd());
		uniform_int_distribution<int> disN(1, 1000);
		uniform_int_distribution<int> disXY(-1e6, 1e6);

		freopen((to_string(ii) + ".in").c_str(), "w", stdout);

		int n = disN(mt);
		cout << n << endl;

		vector<vector<int>> nums;
		for (int i = 1; i <= n; i++) {
			int x = disXY(mt);
			int y = disXY(mt);
			nums.push_back({x, y});
			cout << x << " " << y << endl;
		}
		fclose(stdout);

		freopen((to_string(ii) + ".out").c_str(), "w", stdout);
		cout << fun(n, nums) << endl;
		fclose(stdout);
	}
	for (int ii = 4; ii <= 6; ii++) {
		random_device sd;
		mt19937 mt(sd());
		uniform_int_distribution<int> disN(1, 5e4);
		uniform_int_distribution<int> disXY(-1e6, 1e6);

		freopen((to_string(ii) + ".in").c_str(), "w", stdout);

		int n = disN(mt);
		cout << n << endl;

		vector<vector<int>> nums;
		for (int i = 1; i <= n; i++) {
			int x = disXY(mt);
			int y = disXY(mt);
			nums.push_back({x, y});
			cout << x << " " << y << endl;
		}
		fclose(stdout);

		freopen((to_string(ii) + ".out").c_str(), "w", stdout);
		cout << fun(n, nums) << endl;
		fclose(stdout);
	}
	for (int ii = 7; ii <= 10; ii++) {
		random_device sd;
		mt19937 mt(sd());
		uniform_int_distribution<int> disN(1, 3e5);
		uniform_int_distribution<int> disXY(-1e6, 1e6);

		freopen((to_string(ii) + ".in").c_str(), "w", stdout);

		int n = disN(mt);
		cout << n << endl;

		vector<vector<int>> nums;
		for (int i = 1; i <= n; i++) {
			int x = disXY(mt);
			int y = disXY(mt);
			nums.push_back({x, y});
			cout << x << " " << y << endl;
		}
		fclose(stdout);

		freopen((to_string(ii) + ".out").c_str(), "w", stdout);
		cout << fun(n, nums) << endl;
		fclose(stdout);
	}
	return 0;
}
